/// @tags:
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

using ll = long long;

constexpr int maxn = 1e7, maxp = 1e6;

bool vis[maxn];
int pri[maxp];

void solve() {
  ll n;
  cin >> n;
  for (int i = 1; i <= pri[0]; ++i) {
    if (n % pri[i] == 0) {
      if (n / pri[i] % pri[i] == 0) {
        cout << pri[i] << ' ' << n / pri[i] / pri[i] << '\n';
        return;
      } else {
        cout << (ll)sqrt(n / pri[i]) << ' ' << pri[i] << '\n';
        return;
      }
    }
  }
}

int main() {
  int t;
  cin >> t;
  for (int i = 2; i < maxn; ++i) {
    if (!vis[i]) {
      pri[++pri[0]] = i;
    }
    for (int j = 1; j <= pri[0] && i * pri[j] < maxn; ++j) {
      vis[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
  while (t--) {
    solve();
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("D - Happy New Year 2023.in", "r", stdin);
  freopen("D - Happy New Year 2023.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
